package atack.tesis.kelluntekun.ui.componentes;

import com.vaadin.terminal.ThemeResource;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.Tree;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.themes.BaseTheme;
import com.vaadin.ui.themes.Reindeer;

/**
 * @author marza
 *
 */
public class sideLeftBar extends VerticalLayout{

	private static final long serialVersionUID = 1L;
	
	private TabSheet t;
	private VerticalLayout vlyCarpetas;
	private HorizontalLayout hlyMenuCarpetas;
	
	private Tree foldersTree; 
	
	private Button btAddFolder;
	private Button btDelFolder;
		
	/**
	 * Crea y construye la barra donde se presentan las carpetas de cada usuario.
	 * 
	 */
	public sideLeftBar(){
		setMargin(false);
		setSpacing(false);
		setWidth("100%");
		setHeight("100%");
		
		t = new TabSheet();
		t.setStyleName(Reindeer.TABSHEET_SMALL);
		t.setSizeFull();

		vlyCarpetas = new VerticalLayout();
		vlyCarpetas.setMargin(false);
		vlyCarpetas.setSpacing(false);
		
		buildMenuCarpetas();
		vlyCarpetas.addComponent(hlyMenuCarpetas);
		
		foldersTree = new Tree();
		foldersTree.setImmediate(true);
		vlyCarpetas.addComponent(foldersTree);
		
		t.addTab(vlyCarpetas, "Carpetas");
		addComponent(t);
	}
	
	
	/**
	 * Construye el menu que contiene los botones para eliminar y crear carpetas.
	 */
	private void buildMenuCarpetas(){
		
		hlyMenuCarpetas = new HorizontalLayout();
		hlyMenuCarpetas.setStyleName(Reindeer.LAYOUT_BLACK);
		hlyMenuCarpetas.setMargin(false);
		hlyMenuCarpetas.setSpacing(true);
		hlyMenuCarpetas.setWidth("100%");
		hlyMenuCarpetas.setHeight(null);
		
		btDelFolder = new Button();
		btDelFolder.setWidth(null);
		btDelFolder.setStyleName(BaseTheme.BUTTON_LINK);
		btDelFolder.setDescription("Borrar Carpeta");
		btDelFolder.setIcon(new ThemeResource("../runo/icons/32/folder-delete.png"));
		hlyMenuCarpetas.addComponent(btDelFolder);
		hlyMenuCarpetas.setComponentAlignment(btDelFolder, Alignment.MIDDLE_LEFT);
		
		btAddFolder = new Button();
		btAddFolder.setStyleName(BaseTheme.BUTTON_LINK);
		btAddFolder.setWidth(null);
		btAddFolder.setDescription("Agregar Carpeta");
		btAddFolder.setIcon(new ThemeResource("../runo/icons/32/folder-add.png"));
		hlyMenuCarpetas.addComponent(btAddFolder);
		hlyMenuCarpetas.setComponentAlignment(btAddFolder, Alignment.MIDDLE_RIGHT);
	}

	/**
	 * Retorna el Arbol donde son mostradas las carpetas de cada usuario.
	 * @return foldersTree
	 */
	public Tree getFoldersTree() {
		return foldersTree;
	}
	
	/**
	 * Retorna el Botón destinado a agregar carpetas del menú de carpetas
	 * @return btAddFolder 
	 */
	public Button getBtAddFolder() {
		return btAddFolder;
	}
	
	/**
	 * Retorna el Botón destinado a eliminar carpetas del menú de carpetas
	 * @return btDelFolder
	 */
	public Button getBtDelFolder() {
		return btDelFolder;
	}
	public void setBtDelFolder(Button btDelFolder) {
		this.btDelFolder = btDelFolder;
	}
}
